#include "dyn_controlChaos_controlOGY.h"

ControlOGY::ControlOGY(MultiMaps* map,
                       mat orbitPoints,
                       colvec initCond,
                       mapsGetPtr getParaPtr,
                       mapsSetPtr setParaPtr,
                       double deltaMax,
                       double epsilonNeighborhood,
                       int controlIterations,
                       int maxIterations,
                       mat contravariantVectors,
                       mat parametricChange)
    : ControlChaos(map, orbitPoints, initCond, getParaPtr, setParaPtr,deltaMax,
                   epsilonNeighborhood, controlIterations,maxIterations)
{
    setContraVec(contravariantVectors);
    setParaVec(parametricChange);
}

double ControlOGY::computeDelta(int orbitPointIndex, rowvec diff)
{
    // We define a variable holding the index
    // of the contravariant vector we need.
    int row = (orbitPointIndex+1) % contraVec.n_rows;

    // We now compute the variation on the parameter.
    double deltaParameter =
            dot(contraVec.row(row),map->jacobian(orbitPoints.row(orbitPointIndex).t(),1)*diff.t())
            /dot(contraVec.row(row),paraVar.row(orbitPointIndex));

    return deltaParameter;
}
